package com.blockmeta.bbs.businesslibrary.util;

import android.text.TextUtils;

import com.blockmeta.bbs.businesslibrary.BuildConfig;


public enum AppCode {
    MAIN("8btc"),
    CHAINNODE("chainnode"),
    QKL123("qkl123"),
    ;

    public String code;

    AppCode(String code) {
        this.code = code;
    }

    public static String getMyAppCode(String appId) {
        String appCode = MAIN.code;
        switch (appId){
            case "com.blockmeta.bbs":
                appCode = MAIN.code;
                break;
            case "com.qkl123.android":
                appCode = QKL123.code;
                break;
            case "com.blockmeta.chainnode":
                appCode = CHAINNODE.code;
                break;
        }
        return appCode;
    }

    public static String transToAppCode(String ua) {
        if (TextUtils.isEmpty(ua)) {
            return MAIN.code;
        }
        String appCode;
        if (ua.contains(MAIN.code)) {
            appCode = MAIN.code;
        } else if (ua.contains(CHAINNODE.code)) {
            appCode = CHAINNODE.code;
        } else if (ua.contains(QKL123.code)) {
            appCode = QKL123.code;
        } else {
            appCode = MAIN.code;
        }
        return appCode;
    }
}
